package com.mobilereports.model;

import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public abstract class ChartModel {
	private Comparator<Sample> comparator;
	protected Map<Double, Integer> sampleIndexMap = new HashMap<Double, Integer>();
	
	
	
	public abstract List<Sample> getSamples(); 
	public abstract void drillDown(Sample sample);
	public abstract void drillUp();
	
	public Comparator<Sample> getComparator() {
		return comparator;
	}
	
	public void setComparator(Comparator<Sample> comparator) {
		this.comparator = comparator;
	}
	
	public double getMaxValue() {
		double max = Double.MIN_VALUE;
		for(Sample s: getSamples()) {
			double v = s.getValue();
			if(max < v) {
				max = v;
			}
		}
		
		return max;
	}
	
	public double getMinValue() {
		double min = Double.MAX_VALUE;
		for(Sample s: getSamples()) {
			double v = s.getValue();
			if(min > v) {
				min = v;
			}
		}
		
		return min;
	}
	
}
